//
//  ScrollFloatProtocol.swift
//  zhonglibang
//
//  Created by Rowling on 2021/1/5.
//

import UIKit
protocol SubScrollDelegate {
    var scrollViewDidScrollBlock : ((UIScrollView) -> ())? { get }
    func scrollView() -> UIScrollView
    func scrollViewDidScroll(_ scrollViewDidScorllBolck:@escaping ((_ scrollView : UIScrollView)->()))
}

protocol ScrollGestureDelegate : NSObjectProtocol {
    func mainScrollShouldRecognizeSimultaneouslyWithGestureRecognizer(gestureRecognizer:UIGestureRecognizer,otherGestureRecognizer:UIGestureRecognizer) -> Bool
}

class ScrollBgView : UIScrollView {
    weak var gestureDelegate : ScrollGestureDelegate?
    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
        if let gestureDelegate = gestureDelegate {
           return gestureDelegate.mainScrollShouldRecognizeSimultaneouslyWithGestureRecognizer(gestureRecognizer: gestureRecognizer, otherGestureRecognizer: otherGestureRecognizer)
        }
        else {
            return gestureRecognizer.isKind(of: UIPanGestureRecognizer.self) && otherGestureRecognizer.isKind(of: UIPanGestureRecognizer.self)
        }
    }
}
